﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NCM_MSTest.Test
{
    [TestClass]
    [TestCategory("矩阵测试")]
    public class 矩阵测试
    {
        [TestMethod]
        public void 输出矩阵()
        {
            int n = 5;
            int m = 8;
            double[,] A = new double[n, m];
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < m; j++)
                {
                    A[i, j] = i * m + j;
                }
            }
            Console.WriteLine($"{n}x{m}");
            A.Print(); //输出矩阵
            Console.WriteLine();
            Console.WriteLine($"{m}x{n}");
            A.PrintInv(); //输出转置矩阵
        }

        [TestMethod]
        public void 矩阵乘法()
        {
            int n = 5;
            int m = 6;
            int l = 5;
            double[,] A = new double[n, m];
            double[,] B = new double[m, l];
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < m; j++)
                {
                    A[i, j] = i * n + j + 1;
                    for (int k = 0; k < l; k++)
                    {
                        B[j, k] = j * m + k + 1;
                    }
                }
            }
            Console.Write("A\t");
            A.PrintF(); //输出矩阵
            Console.Write("B\t");
            B.PrintF(); //输出矩阵
            var C = A.Times(B);
            Console.Write("C\t");
            C.PrintF(); //输出矩阵
        }
    }
}
